/**
 * author: sailing
 * date: 2018/11/15
 */

export default {
	getTime () {
		var myDate = new Date();
		var year = myDate.getFullYear();
		var month = myDate.getMonth() + 1;
		var day = myDate.getDate();

		var h = myDate.getHours(); 
		var m = myDate.getMinutes(); 
		var s = myDate.getSeconds();

		return year + '-' + month + '-' + day + " " + h + ':' + m + ':' + s
	},
	getParams () {
      var url = window.location.href
      var urlarr = url.split("?")[1]
      var obj = {}
      if(urlarr) {
        var params = urlarr.split("&")
        for(var i=0; i< params.length; i++){
          var gpar = params[i].split("=")
          console.log("gpar:", gpar)
          obj[gpar[0]] = gpar[1]
        }
      }
      return obj
  	},
  isWeixin(){
    var ua = navigator.userAgent.toLowerCase();
    var isWeixin = ua.indexOf('micromessenger') != -1;
    if (isWeixin) {
        return true;
    }else{
        return false;
    }
  },
	jsonToStr(json) {
        var str = ''
        if (json) {
            for (var i in json) {
                if (str === '') {
                    str = i + '=' + json[i]
                } else {
                    str += '&' + i + '=' + json[i]
                }
            }
        }
        return str
    },
	uuid () {
		var mydate = new Date()
		var uuid = "cms"+mydate.getDay()+ mydate.getHours()+ mydate.getMinutes()+mydate.getSeconds()+mydate.getMilliseconds()
		return uuid
	}
}  